package db

import (
	"github.com/gin-gonic/gin"
	"github.com/redis/go-redis/v9"
	"ubt-gin-admin/app/pkg/conf"
)

var RdsCli = &redis.Client{}

func Redis(ctx *gin.Context) {
	cfg := conf.Conf.Redis
	RdsCli = redis.NewClient(&redis.Options{
		Addr:     cfg.IpPort,
		Password: cfg.Passwd,
		DB:       cfg.DbNum,
	})
	if _, err := RdsCli.Ping(ctx).Result(); err != nil {
		panic("缓冲Redis初始化失败。" + err.Error())
		return
	}
}
